package com.colin.aiyi.dao.ImpxUtils;

import com.colin.aiyi.app.Constant;
import com.colin.aiyi.entity.response.BaseResponse;
import com.colin.aiyi.entity.User;

import org.xutils.http.RequestParams;

/**
 * Created by hl on 2017/6/12.
 */

public class ImpMsgRead extends AbsServicexUtils {

    @Override
    public void onSuccess(String result) {
        super.onSuccess(result);
        if (callback==null)
        {
            sendMsgToView(BaseResponse.class,result);
        }else {
            BaseResponse loginResponse=gson.fromJson(result,  BaseResponse.class);
            callback.onSuccess(loginResponse);
        }
    }

    @Override
    public <V> void getObject(V v) {
        super.getObject(v);
        if (v instanceof User) {
            User user = (User) v;
            RequestParams params = new RequestParams(Constant.msg_read);
            params.addBodyParameter("accessToken", user.getAccessToken());
            params.addBodyParameter("clientId", Constant.CLIENT_ID);
            params.addBodyParameter("clientSecret", Constant.CLIENT_SECRET);
            params.addBodyParameter("id", user.getId()+"");
//            params.addBodyParameter("password", user.getPassword());
//            params.addBodyParameter("messageCode", user.getMessageCode());
            sendToServer(params);
        }
    }
}
